package com.exam.paper.controller;

import com.exam.common.entity.Request;
import com.exam.paper.service.WrongService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName : WrongController
 * @Description : 错题本
 * @Author : WHB
 */
@RestController
@RequestMapping("wrong")
@Api(description = "错题本API接口")
public class WrongController {

    @Autowired
    private WrongService wrongService;

    @PostMapping("")
    @ApiOperation(value="新增错题", notes="新增错题")
    public Request addWrong(@RequestParam("uid") Long uid,@RequestParam("sid") Long sid){
        wrongService.addWrong(uid,sid);
        return new Request(true,200,"成功添加到错题本");
    }

    @DeleteMapping("")
    @ApiOperation(value="删除错题", notes="删除错题")
    public Request deleteWrong(@RequestParam("id") Long id){
        wrongService.deleteWrong(id);
        return new Request(true,200,"已删除错题");
    }

    @GetMapping("{page}/{size}")
    @ApiOperation(value="分页查看错题", notes="分页查看错题")
    public Request queryWrongList(@RequestParam("uid") Long uid,
                                  @PathVariable("page") Integer page,
                                  @PathVariable("size") Integer size){

        return new Request(true,200,"错题本查找成功",wrongService.queryWrongList(uid,page,size));
    }



}
